﻿using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;

namespace TopShooter.Animations
{
	public abstract class EntityAnimation
	{
		public Entity Entity;
		public SoundEffect MainSound;
        public Action<EntityAnimation> Removed;

		public EntityAnimation(Entity e)
		{
			Entity = e;
		}

		abstract public void Update(GameTime gameTime);

		public virtual void Remove()
		{
			if (Entity != null)
			{
				int index = Entity.Effects.IndexOf(this);
				if (index >= 0)
				{
					Entity.Effects.RemoveAt(index);
					OnRemoved();
				}
			}
		}

		protected virtual void OnRemoved()
		{

            if (Removed != null)
                Removed(this);
			// code?
		}

	}
}
